package com.sphd.education.activitys;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.GridView;

import com.sphd.education.R;
import com.sphd.education.adapter.ImageShowLessonAdapter;
import com.sphd.education.adapter.ImageShowSchoolAdapter;
import com.sphd.education.base.BaseActivity;
import com.sphd.education.info.EducationIntentKey;
import com.sphd.education.info.SchoolImgInfo;
import com.sphd.education.info.SchoolInfo;
import com.sphd.education.info.SchoolTeacherImgInfo;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/***
 * 图片显示列表
 */
public class ImageShowActivity extends BaseActivity {
    @Bind(R.id.toolbar)
    Toolbar toolbar;
    @Bind(R.id.my_gridView)
    GridView myGrid;
    ImageShowLessonAdapter imageShowAdapter;
    ImageShowSchoolAdapter imageShowSchoolAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_image_show);
        ButterKnife.bind(this);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();//这是自带的箭头的返回的监听
            }
        });
        initView();
    }

    @Override
    public void initView() {
        Intent intent = getIntent();
        Bundle bundle = intent.getBundleExtra(EducationIntentKey.FLAG);
        Log.e("bundle2", bundle.getString("type") + "");
        if (bundle.getString("type").equals(EducationIntentKey.SEARCH_LESSON_IMAGE.toString())) {
            getSupportActionBar().setTitle("师资力量");
            SchoolInfo schoolInfo = (SchoolInfo) bundle.getSerializable(EducationIntentKey.SEARCH_LESSON_IMAGE);
            List<SchoolTeacherImgInfo> list = schoolInfo.getSchoolTeacherImgInfoList();
            imageShowAdapter = new ImageShowLessonAdapter(this, list);
            myGrid.setAdapter(imageShowAdapter);
        } else if (bundle.getString("type").equals(EducationIntentKey.SEARCH_SCHOOL_IMAGE.toString())) {
            getSupportActionBar().setTitle("教学环境");
            SchoolInfo schoolInfo = (SchoolInfo) bundle.getSerializable(EducationIntentKey.SEARCH_SCHOOL_IMAGE);
            List<SchoolImgInfo> list = schoolInfo.getSchoolImgInfoList();
            imageShowSchoolAdapter = new ImageShowSchoolAdapter(this, list);
            myGrid.setAdapter(imageShowSchoolAdapter);
        }
        myGrid.setVerticalSpacing(10);
        myGrid.setHorizontalSpacing(10);

    }

    @Override
    public void findViewById() {

    }

    @Override
    public void myNet() {

    }
}
